const columns = [
  { title: '名称', dataIndex: 'slotName', key: 'slotName' },
  { title: 'pv', dataIndex: 'activityShowPv', key: 'activityShowPv' },
  { title: 'uv', dataIndex: 'activityShowUv', key: 'activityShowUv' },
  { title: '活动参与', dataIndex: 'activityJoinPv', key: 'activityJoinPv', sorter: (a, b) => a.activityJoinPv - b.activityJoinPv },
  {
    title: '每uv参与',
    dataIndex: 'customUv',
    key: 'customUv',
    // 处理列排序
    sorter: (a, b) => {
      let aCustomUv = a.activityJoinPv / a.activityShowUv
      let bCaustomUv = b.activityJoinPv / b.activityShowUv
      if (isNaN(aCustomUv)) {
        aCustomUv = 0
      }
      if (isNaN(bCaustomUv)) {
        bCaustomUv = 0
      }
      return aCustomUv - bCaustomUv
    },
    scopedSlots: { customRender: 'customUv' },
  },
  { title: '广告曝光', dataIndex: 'advertShowPv', key: 'advertShowPv', sorter: (a, b) => a.advertShowPv - b.advertShowPv },
  { title: '广告有效点击', dataIndex: 'advertValidClick', key: 'advertValidClick' },
  {
    title: '点击率',
    dataIndex: 'customClick',
    key: 'customClick',
    scopedSlots: { customRender: 'customClick' },
    // 处理列排序
    sorter: (a, b) => {
      let aCustomClick = a.advertValidClick / a.advertShowPv
      let bCustomClick = b.advertValidClick / b.advertShowPv
      if (isNaN(aCustomClick)) {
        aCustomClick = 0
      }
      if (isNaN(bCustomClick)) {
        bCustomClick = 0
      }
      return aCustomClick - bCustomClick
    },
  },
  { title: '预估收入', dataIndex: 'expectIncome', key: 'expectIncome', scopedSlots: { customRender: 'expectIncome' } },
]

const data = [
  {
    key: '0',
    id: '20',
    advertPlanName: '极准-水滴保01-计划04',
    advertShowPv: '4557',
    advertValidClick: '1357',
    ctr: '29.16%',
    expectIncome: '265.40',
    date: '2021-6-30',
    innerData: [
      { key: 0, date: '2020-7-3' },
      { key: 1, date: '2020-7-4' },
    ],
  },
  {
    key: '1',
    id: '21',
    advertPlanName: '极准-水滴保01-计划04',
    advertShowPv: '2557',
    advertValidClick: '2357',
    ctr: '0%',
    expectIncome: '65',
    date: '2021-7-1',
    innerData: [
      { key: 2, date: '2020-7-5' },
      { key: 3, date: '2020-7-6' },
    ],
  },
]
const innerColumns = [
  { title: '日期', dataIndex: 'computeTime', key: 'computeTime' },
  { title: 'pv', dataIndex: 'activityShowPv', key: 'activityShowPv' },
  { title: 'uv', dataIndex: 'activityShowUv', key: 'activityShowUv' },
  { title: '活动参与', dataIndex: 'activityJoinPv', key: 'activityJoinPv' },
  { title: '每uv参与', dataIndex: 'customUv', key: 'customUv', scopedSlots: { customRender: 'customUv' } },
  { title: '广告曝光', dataIndex: 'advertShowPv', key: 'advertShowPv' },
  { title: '广告有效点击', dataIndex: 'advertValidClick', key: 'advertValidClick' },
  { title: '点击率', dataIndex: 'advertClickRate', key: 'advertClickRate', scopedSlots: { customRender: 'advertClickRate' } },
  { title: '预估收入', dataIndex: 'expectIncome', key: 'expectIncome', scopedSlots: { customRender: 'expectIncome' } },
]

export { columns, data, innerColumns }
